﻿/**************************************************************************************************\
++++++++++++++++++++++++++++++ ARKADIUM INTELLECTUAL PROPERTY TERMS ++++++++++++++++++++++++++++++
The Software is protected by US copyright laws and international treaties. Licensee must treat the 
Software like any other copyrighted material – for example a book. Licensee acknowledges that 
Arkadium owns the Software and that nothing set forth herein conveys to Licensee any ownership in 
or to the Software, including without any Derivative Works of the Software.  
++++++++++++++++++++++++++++++ ARKADIUM INTELLECTUAL PROPERTY TERMS ++++++++++++++++++++++++++++++

AUTHOR: Neil Mrva

PURPOSE: 
This file contains code that is copied into the first frame of the timeline in order to 
monitor the loading progress of the entire SWF. The "this" pointer used in this file is equal to
_root and the main timeline.
\**************************************************************************************************/

// This check is here in case this movie is loaded by another SWF. If so, the movie is 100%
// loaded and we can go straight to the initialization frame. If not we stop here and set
// up an onEnterFrame event to keep track of the load progress. If we don't have this check
// here you will see the first frame flicker becuase the onEnterFrame event won't fire until 
// one frame later.
if ( this.getBytesLoaded() == this.getBytesTotal() )
{
	this.gotoAndStop( "Main" );
}
else
{
	// Since we export our AS2 classes, dynamic movieclips, and game movieclips on frame 2, 3, and 10
	// respectively we need to stop here on the first frame and monitor load progress.
	stop();

	// Because we restrict the monitoring on the first frame by stoping the movie, we need to have 
	// an onEnterFrame handler to do the monitoring.
	this.onEnterFrame = trackProgress;
}

/**************************************************************************************************\
trackProgress - This function is in charge of updating progress montiors on stage and skipping to 
the main game frame once the SWF is completelt loaded.
\**************************************************************************************************/
function trackProgress()
{
	// Let's get the amount of bytes currently loaded vs the total bytes in order to display a 
	// text percentage or load bar.
	var nPercentComplete:Number = ( this.getBytesLoaded() / this.getBytesTotal() ) * 100;
	
	// Update the load status moviclips contained on stage.
	//this._smcPreLoader._sdtPercent.text = Math.round( nPercentComplete ) + "%";
	this._smcPreLoader._smcLoadBar._xscale = nPercentComplete;

	// If the percentage reaches 100, our SWF is completely loaded. 
	// At this point we're safe to jump to the "main" game frame to start our game logic.
	// Since we don't need to monitor loading, we delete the onEnterFrame handler.
	if ( nPercentComplete == 100 )
	{
		this.gotoAndStop( "Main" );
		delete this.onEnterFrame;
	}
}